package com.wangwenjun.concurrency.chapter14.atomicstampedreference;

import java.util.concurrent.atomic.AtomicStampedReference;

/**
 * @Package: com.wangwenjun.concurrency.chapter14.atomicstampedreference
 * @ClassName: UseAtomicStampedReference
 * @Author: lujieni
 * @Description: 使用AtomicStampedReference的细节,尽量不要使用包装类当做泛型,而应该是一个具体的pojo
 * @Date: 2021-03-22 09:32
 * @Version: 1.0
 */
public class UseAtomicStampedReference {

    public static void main(String[] args) {
        AtomicStampedReference<Integer> atomicStampedReference = new AtomicStampedReference<>(2020,1);
        /*
           Integer a = 2155;

           Integer b = 2155;

           System.out.println(a == b);

           compareAndSet中的源码会先拿2020和Pair.reference进行==比较,由于Integer大于255
           的时候是重新new了一个对象,所以不能这么玩
         */

        System.out.println(atomicStampedReference.compareAndSet(2020, 2022, 1, 2));

    }


}